
<link href='<?php print ASSETS_URL?>/js/jqueryPlugins/jqgrid/css/ui.jqgrid.css' rel='stylesheet' type='text/css'>
 
<script type='text/javascript' src='<?php print ASSETS_URL?>/js/jqueryPlugins/jqgrid/js/jquery.jqGrid.min.js'></script>
<script type='text/javascript' src='<?php print ASSETS_URL?>/js/jqueryPlugins/jqgrid/js/i18n/grid.locale-ro.js'></script> 
<div class="my-account form-container">
	<div class="col-left sidebar">
		<div class="block block-account">
			<div class="block-title">
				<strong>
					<span><?=lang('my_account')?></span>
				</strong>
			</div>
			<div class="block-content">
				<ul>
					<li>
						<a href="<?=site_url('user/my_account/')?>">
							<?=lang('account_info')?>
						</a>
					</li>
					<li>
						<a href="<?=site_url('user/my_address/')?>">
							<?=lang('my_address')?>
						</a>					
					</li>
					<li class="current">
						<strong>
							<?=lang('my_orders')?>
						</strong>					
					</li>
					<li class="last">
						<a href="<?=site_url('user/logout/')?>">
							<?=lang('logout')?>
						</a>
					</li>
				</ul>
			</div>
		</div>
	</div>
	<div class="col-main">
		<div class="lpadding10">
			<table id="grid1"  ></table>
			<div id="pgrid1"></div> 
		</div>
	</div>
	<div class="clear"></div>

</div>

<?php // echo $output; ?>
<div id="orderDialog" class="hide">

</div>
<div id="orderCommentDialog" class="hide">
<div id="question-status-success" class="message ui-state-highlight hide"></div>
<div id="question-status-error" class="message ui-state-error hide"></div>

<div id="imageContent" class="hide"></div>
<table id ="loader_content" border="0" align="center">
  <tr>
    <td><div class="loader"></div></td>
  </tr>
 </table>

<div id="textContainer" class="hide">
	<div class="clear"></div>
	<label><?php echo lang("your_opinion")?>:</label>
	<textarea style="width:450px" id="producComment"></textarea> 
	<input type="hidden" id="pordId" val=''>
</div>
</div>
<div id="valuationOrder" class="hide">
	<div id="showValuationOrder" class="hide"></div>
	<table id ="loader_content_valutation" border="0" align="center">
		  <tr>
			<td><div class="loader"></div></td>
		  </tr>
	</table>
</div>
<div id="invoiceOrder" class="hide">
	<div id="showInvoiceOrder" class="hide"></div>
	<table id ="loader_content_invoice" border="0" align="center">
		  <tr>
			<td><div class="loader"></div></td>
		  </tr>
	</table>
</div>
<script type="text/javascript">
function orderDetails(id){
	$( "#orderDialog" ).dialog({
		resizable: false,
		height:140,
		modal: true,
		buttons: {
			Cancel: function() {
				$( this ).dialog( "close" );
			}
		}
	});
}
var cancel = '[cancel]';
if (lang.cancel != undefined) {
	cancel = lang.cancel;
}
var invoice = '[invoice]';
if (lang.invoice != undefined) {
	invoice = lang.invoice;
}
var valuation_document = '[valuation_document]';
if (lang.valuation_document != undefined) {
	valuation_document = lang.valuation_document;
}
function showValuationOrder(id){
$('#loader_content_valutation').show();
$( "#valuationOrder" ).dialog({
					modal: true,
					resizable: true,
					width: 820,
					title: valuation_document,
					buttons: [
						{
							text: cancel,
							click: function() {
								$('#showValuationOrder').html('');
								$(this).dialog('close');
							}
						}	
					]
				});
	$.ajax({
		url: settings.base_url + lang.lang_key + '/user/showValuationOrder/'+ id,
		dataType: 'html',
		type: 'POST',
		success: function(data){
			$('#showValuationOrder').html(data);
			$('#loader_content_valutation').hide();
			$('#showValuationOrder').show();
		},
		complete: function() {
		}
	});					
}
function showInvoice(id, rate){
$('#loader_content_invoice').show();
$( "#invoiceOrder" ).dialog({
					modal: true,
					resizable: true,
					width: 820,
					title: invoice,
					buttons: [
						{
							text: cancel,
							click: function() {
								$(this).dialog('close');
								$('#showInvoiceOrder').html('');
							}
						}	
					]
				});
	$.ajax({
		url: settings.base_url + lang.lang_key + '/user/showInvoice/'+ id + '/'+rate,
		dataType: 'html',
		type: 'POST',
		success: function(data){
			$('#showInvoiceOrder').html(data);
			$('#loader_content_invoice').hide();
			$('#showInvoiceOrder').show();
		},
		complete: function() {
		}
	});					
}

function addOrderComment(orderid){
	var add_your_opinion = '[add_your_opinion]';
	if (lang.add_your_opinion != undefined) {
		add_your_opinion = lang.add_your_opinion;
	}
	var select_a_product_error = '[select_a_product_error]';
	if (lang.select_a_product_error != undefined) {
		select_a_product_error = lang.select_a_product_error;
	}

	var opinion_filed_is_required = '[opinion_filed_is_required]';
	if (lang.opinion_filed_is_required != undefined) {
		opinion_filed_is_required = lang.opinion_filed_is_required;
	}
	
	$( "#orderCommentDialog" ).dialog({
		modal: true,
		resizable: true,
		width: '480',
		title: add_your_opinion,
		buttons: [
			{
				id: "add_your_opinion",
				text: add_your_opinion,
				click: function() {
					if ($("#pordId").val() == ''){
						$("#question-status-error").html(select_a_product_error).show();
					}
					if ($("textarea#producComment").val() == ''){
						$("#question-status-error").html(opinion_filed_is_required).show();
					}	
						$.ajax({
							url: settings.base_url + lang.lang_key + '/opinion/save_opinion',
							dataType: 'json',
							type: 'POST',
							data: {'product_id': $("#pordId").val(), 'opinion': $("textarea#producComment").val()},
							success: function(data){
								$("#question-container").hide();
								$("#button-ask").hide();
								if (data.status == "1") {
									$( "#question-status-success" ).html(data.msg);
									$( "#question-status-success" ).show();
									return false;
								} else {
									$( "#question-status-error" ).html(data.msg);
									$( "#question-status-error" ).show();
								}
							},
							complete: function() {
							}
						});	
													
				}
			},
			{
				text: cancel,
				click: function() {
					$(this).dialog('close');
				}
			}	
		]
	});
	
	$.ajax({
		url: settings.base_url + lang.lang_key + '/user/orderProductImages/'+ orderid,
		dataType: 'html',
		type: 'POST',
		success: function(data){
				$('#loader_content').hide();
				$('#imageContent').html(data);
				$('#imageContent').show();
				$('#textContainer').show();
				$(".checkbox").bind("click", function() {
					var this_obj = this;
					$(".checkbox").each(function(){
				        $(this).removeClass("checked");
				    });
					$(this_obj).toggleClass('checked');
					$(this_obj).unbind("click");
					$("#pordId").val($(this_obj).attr("rel"));
				});
		},
		complete: function() {
		}
	});					
}

function anonim(){
	var ask = '[ask]';
	if (lang.ask != undefined) {
		ask = lang.ask;
	}

	var modal_title = '[ask_the_jeweler]';
	if (lang.ask_the_jeweler != undefined) {
		ask = lang.ask_the_jeweler;
	}

	var cancel = '[cancel]';
	if (lang.cancel != undefined) {
		cancel = lang.cancel;
	}

	$( "#ask_the_jeweler" ).dialog({
		autoOpen: false,
		height: 250,
		width: 400,
		modal: true,
		buttons: [
			{
				id: "button-ask",
				text: ask,
				click: function() {
					if ($("#ask_the_jeweler").valid()){	
						$.ajax({
							url: settings.base_url + lang.lang_key + '/product/save_question',
							dataType: 'json',
							type: 'POST',
							data: {
								form_data : $('#ask_the_jeweler').serialize()
							},
							success: function(data){
								$("#question-container").hide();
								$("#button-ask").hide();
								if (data.status == "1") {
									$( "#question-status-success" ).show();
									return false;
								} else {
									$( "#question-status-error" ).show();
								}
							},
							complete: function() {
							}
						});	
					}									
				}
			},
			{
				text: cancel,
				click: function() {
					$(this).dialog('close');
				}
			}			
		],
		close: function() {
			$('#question').val('');
		},
		open: function(){
			$("#question-container").show();
			$(".message").hide();
			$("#button-ask").show();
		},
		title : modal_title
	});
}

$("#ask_the_jeweler_btn").click(function(){
	$( "#ask_the_jeweler" ).dialog('open');
});

jQuery("#grid1").jqGrid({
    datatype: "local",
    height: 'auto',
    width: '800',
    url: '<?=site_url('user/jqgrid_show/')?>',
    datatype: "json",
    colNames: [
		'<?=lang('order_id')?>',
    	'<?=lang('date')?>',
    	'<?=lang('shipping_info')?>',
    	'<?=lang('status')?>', 
    	'<?=lang('acction')?>'
    	],
    colModel: [
       {name: 'id', index: 'id',width: 40, align:'center',fixed:true}, 
       {name: 'data_add',index: 'data_add',width: 70,fixed:true},
       {name: 'shipping_info',index: 'shipping_info',width:150,fixed:true},
       {name: 'status',index: 'status',width: 40,fixed:true},
       {name: 'acction',index: 'acction',width:150,fixed:true}
    ],
    rowNum:5, 
    viewrecords: true,
    
    caption: '<?=lang('my_orders')?>',
    pager: '#pgrid1'
    
});
jQuery("#grid1").jqGrid('navGrid','#pgrid1',{edit:false,add:false,del:false,search:false});
</script>
<!-- '<?=lang('confirmed')?>', '<?=lang('order_type')?>',  -->